﻿using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Sys;
using Rhonin.Common.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.Mongo.Sys.Impl
{
    [Component(LifeStyle.Singleton)]
    public class SysRoleQueryService : ISysRoleQueryService
    {
        private readonly ISysRepository<SysRole> _sysRoleRepository;
        public SysRoleQueryService(ISysRepository<SysRole> sysRoleRepository)
        {
            _sysRoleRepository = sysRoleRepository;
        }

        public SysRole Get(Expression<Func<SysRole, bool>> where)
        {
            return _sysRoleRepository.GetQuery().FirstOrDefault(where);
        }

        public List<SysRole> GetList(Expression<Func<SysRole, bool>> where)
        {
            return _sysRoleRepository.GetQuery().Where(where).ToList();
        }
    }
}
